/*
 * @Author: fanyaqing
 * @Date: 2021-08-11 09:22:27
 * @LastEditTime: 2021-08-11 17:00:35
 * @LastEditors: fanyaqing
 * @Description: 
 * @FilePath: \supermall\src\common\mixin.js
 */
import {debounce} from './utils'
import BackTop from 'components/content/backTop/BackTop'

export const itemListenerMixin={
  data() {
    return {
      itemImgListener:null
    }
  },
  mounted() {
    const refresh=debounce(this.$refs.scroll.refresh,200)
    this.itemImgListener=()=>{
      refresh();
    }
    this.$bus.$on('imageLoaded',this.itemImgListener)
    console.log('我是混入的内容')
  },
}

export const backTopMixin={
  components:{
    BackTop
  },
  data() {
    return {
      backTopShow:false,
    }
  },
  methods: {
    backClick(){
      this.$refs.scroll.scrollTop(0,0);
    },
    listenShowBackTop(position){
      // Math.abs(position.y)>700?this.backTopShow=true:this.backTopShow=false;
      this.backTopShow=Math.abs(position.y)>700;
    },
  },
}
